package com.example.demo.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Objects;

@Entity
public class Bjmxinfo {
    private int bjmxId;
    private String cp;
    private Integer number;
    private BigDecimal price;
    private BigDecimal je;
    private Date cjdate;
    private Client kh;
    private Bjinfo bj;
    private User syr;

    @Id
    @Column(name = "bjmxId", nullable = false)
    public int getBjmxId() {
        return bjmxId;
    }

    public void setBjmxId(int bjmxId) {
        this.bjmxId = bjmxId;
    }

    @Basic
    @Column(name = "cp", nullable = true, length = 20)
    public String getCp() {
        return cp;
    }

    public void setCp(String cp) {
        this.cp = cp;
    }

    @Basic
    @Column(name = "number", nullable = true)
    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    @Basic
    @Column(name = "price", nullable = true, precision = 2)
    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    @Basic
    @Column(name = "je", nullable = true, precision = 2)
    public BigDecimal getJe() {
        return je;
    }

    public void setJe(BigDecimal je) {
        this.je = je;
    }

    @Basic
    @Column(name = "cjdate", nullable = true)
    public Date getCjdate() {
        return cjdate;
    }

    public void setCjdate(Date cjdate) {
        this.cjdate = cjdate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Bjmxinfo bjmxinfo = (Bjmxinfo) o;
        return bjmxId == bjmxinfo.bjmxId &&
                Objects.equals(cp, bjmxinfo.cp) &&
                Objects.equals(number, bjmxinfo.number) &&
                Objects.equals(price, bjmxinfo.price) &&
                Objects.equals(je, bjmxinfo.je) &&
                Objects.equals(cjdate, bjmxinfo.cjdate);
    }

    @Override
    public int hashCode() {
        return Objects.hash(bjmxId, cp, number, price, je, cjdate);
    }

    @ManyToOne
    @JoinColumn(name = "khId", referencedColumnName = "client_id")
    public Client getKh() {
        return kh;
    }

    public void setKh(Client kh) {
        this.kh = kh;
    }

    @ManyToOne
    @JoinColumn(name = "bjId", referencedColumnName = "bjId")
    public Bjinfo getBj() {
        return bj;
    }

    public void setBj(Bjinfo bj) {
        this.bj = bj;
    }

    @ManyToOne
    @JoinColumn(name = "syrId", referencedColumnName = "uid")
    public User getSyr() {
        return syr;
    }

    public void setSyr(User syr) {
        this.syr = syr;
    }
}
